﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Gift.DAL;
using Gift.Model;
using System.Data;

namespace WebSite.cn
{
    public partial class userinfo : BasePage
    {
        readonly MemberAccount theMemberAccount = new MemberAccount();
        readonly DALCard theCard = new DALCard();
        readonly Member theMember = new Member();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (base.LoginUserMember == null || string.IsNullOrEmpty(base.LoginUserMember.MemberId))
                {
                    Response.Redirect("/cn/userLogin.html");
                    this.container.Visible = false;
                   // this.Page.ClientScript.RegisterClientScriptBlock(this.Page.ClientScript.GetType(),"login", "<script langueage='javascript'></script>");
                    return;
                }
                this.BindCardList();
            }
        }

        public string GetAccountMoney()
        {

            if (base.LoginUserMember == null || string.IsNullOrEmpty(base.LoginUserMember.MemberId))
            {
                return "0";
            }
            else
            {
                return theMemberAccount.GetRemainSumMoney(int.Parse(base.LoginUserMember.MemberId)).ToString();

            }
        }



        private void BindCardList()
        {
            if (base.LoginUserMember != null && !string.IsNullOrEmpty(base.LoginUserMember.MemberId))
            {
                DataTable table1;

                table1 = theMemberAccount.GetListByMemberId(int.Parse(base.LoginUserMember.MemberId)).Tables[0];
                if (table1 != null)
                {
                    this.GridView1.DataSource = table1;
                    this.GridView1.DataBind();
                }

          
            }

        }

    }
}